"""
Input:
4
1 1 2 2
Output:
2

Input:
10
1 1 1 1 1 9 8 3 7 10
Output:
3
"""

"""
dfs(i,c) = min(dfs(i-1,c), dfs(i-1, c-x) + 1)
"""

def main():
    n = int(input())
    weights = list(map(int, input().split()))
    
    target = sum(weights)
    if target % 2 != 0:
        print(-1)
        return
    target //= 2
    
    f = [n] * (target + 1)
    f[0] = 0
    
    for x in weights:
        for c in range(target, x-1, -1):
            f[c] = min(f[c], f[c-x]+1)
    print(f[target])
    
    # dfs 的定义是前 i 个里面要满足 c 最少选多少个石头
    # def dfs(i,c):
    #     if i < 0:
    #         return 0 if c == 0 else n
        
    #     if weights[i] > c:
    #         return dfs(i-1, c)
        
    #     return min(dfs(i-1, c), dfs(i-1, c-weights[i]) + 1)
        

if __name__ == "__main__":
    main()